#ifndef _OBSERVER_H_
#define _OBSERVER_H_

#include <iostream>
#include <vector>

using namespace std;

class Subject;

class IObserver
{
public:
	virtual void Update(const Subject* sub) = 0;
	virtual ~IObserver(){};
};

class ConCreteObserverA : public IObserver
{
public:
	virtual ~ConCreteObserverA(){};
	virtual void Update(const Subject* sub);
};

class ConCreteObserverB : public IObserver
{
public:
	virtual ~ConCreteObserverB(){};
	virtual void Update(const Subject* sub);
};

class ConCreteObserverC : public IObserver
{
public:
	virtual ~ConCreteObserverC(){};
	virtual void Update(const Subject* sub);
};

//////////////////////////////////////////////////

class Subject
{
public:
	void Attach(IObserver* obs);
	void Detach(IObserver* obs);
	void Notify();

	void SetState(const string& state);
	string GetState() const;
private:
	typedef vector<IObserver*>::iterator ObsIter;
	
	vector<IObserver*> _obsers;
	string _state;
};

#endif